package org.luxor.common.opencv.config.properties;

import org.luxor.commons.core.utils.SystemUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * Opencv 全局配置
 *
 * @author Mr.Yan  @date: 2022/04/06
 */
@ConfigurationProperties(prefix = OpencvProperties.PREFIX)
public class OpencvProperties {
    public static final String PREFIX = "spring.opencv";

    private final Boolean DEFAULT_ENABLED = Boolean.TRUE;
    private final String DEFAULT_WINDOWS_LIBRARY_PATH = "C:\\Windows\\System32\\opencv_java3416.dll";
    private final String DEFAULT_LINUX_LIBRARY_PATH = "/usr/lib/libopencv_java3416.so";
    private final String DEFAULT_MACOSX_LIBRARY_PATH = "/Library/Java/Extensions/libopencv_java3416.dylib";

    /**
     * 是否启用
     */
    private boolean enabled;

    /**
     * 本地动态库文件路径
     */
    private String libraryPath;

    public OpencvProperties() {
        this.enabled = DEFAULT_ENABLED.booleanValue();
        switch (SystemUtils.getOsType()) {
            case WINDOWS:
                this.libraryPath = DEFAULT_WINDOWS_LIBRARY_PATH;
                break;
            case LINUX:
                this.libraryPath = DEFAULT_LINUX_LIBRARY_PATH;
                break;
            case MACOSX:
                this.libraryPath = DEFAULT_MACOSX_LIBRARY_PATH;
                break;
            case UNKNOWN:
                break;
        }
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getLibraryPath() {
        return libraryPath;
    }

    public void setLibraryPath(String libraryPath) {
        this.libraryPath = libraryPath;
    }
}
